package cn.tutu.blockchain.eth.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import cn.tutu.blockchain.common.Page;
import cn.tutu.blockchain.eth.dao.EthRecordDao;
import cn.tutu.blockchain.eth.entity.EthRecord;
import cn.tutu.blockchain.eth.service.EthRecordService;

@Service
@Transactional
public class EthRecordServiceImpl implements EthRecordService {

	@Autowired
	private EthRecordDao ethRecordDao;

	@Override
	public PageInfo<EthRecord> getByUserId(String userId, Page page) {
		PageHelper.startPage(page.getPageNum(), page.getPageSize());
		List<EthRecord> list = ethRecordDao.findByUserId(userId);
		PageInfo<EthRecord> pageInfo = new PageInfo<EthRecord>(list);
		return pageInfo;
	}

	@Override
	public void create(EthRecord ethRecord) {
		ethRecordDao.insert(ethRecord);
	}

}
